<template>


	<view class="content">
		<view v-if="error"> 参数错误，请重新扫描二维码进入 </view>
		<view v-if="!error">
			<view class="title">{{oname}} 人员出入登记</view>
			<view class="list-item">姓名： {{realName}}</view>
			<view class="list-item">手机：{{phone}}</view>
			<view class="list-item">住址：{{address}}</view>
			<view class="list-item-no">健康声明</view>
			<view class="list-item-mul">
				<text>本人确认无发烧、咳嗽等肺炎疑似症状，没有接触湖北及周边地区人员</text>
				<radio-group class="uni-radio-group" @change="jksmChanged">
					<label class="uni-list-cell " v-for="(item, index) in ['是', '否']" :key="item">
						<view>
							<radio :value="item" :checked="item === jksm" />
						</view>
						<view>{{item}}</view>
					</label>
				</radio-group>
			</view>

			<view class="list-item-no">体温情况</view>
			<view class="list-item-mul">
				<radio-group class="uni-radio-group-col" @change="twChanged">
					<label class="uni-list-cell " v-for="(item, index) in ['是', '否']" :key="item">
						<view>
							<radio :value="item" :checked="item === tw" />
						</view>
						<view v-if="index === 0">正常(低于37.3度)</view>
						<view v-if="index === 1">异常(37.3度或以上)</view>
					</label>
				</radio-group>
			</view>

			<view class="list-item-no">进出小区/单位</view>
			<view class="list-item-mul">
				<radio-group class="uni-radio-group" @change="inoutChanged">
					<label class="uni-list-cell " v-for="(item, index) in ['进', '出']" :key="item">
						<view>
							<radio :value="item" :checked="item === inout" />
						</view>
						<view v-if="index === 0">进</view>
						<view v-if="index === 1">出</view>
					</label>
				</radio-group>
			</view>

			<view class="list-item-no">备注</view>
			<view class="list-item-mul">

				<view class="uni-textarea" style="height: 100px;">
					<textarea @blur="remarkBlur" placeholder="其他情况备注" :value="remark" />
					</view>
			</view>
			<button type="primary" @click="submit">提交</button>
	</view>
</view>
</template>

<script>
	export default {
		data() {
			return {
				realName: '',
				phone: '',
				address: '',
				jksm: '是',
				tw: '是',
				inout:'进',
				remark:'',
				oid:'',
				oname:'',
				code : '',
				error:true
			}
		},
		onLoad(params) {
			this.code = params.code;
			this.oid = params.oid;
			this.oname = params.oname;
			console.log(params)
			if(this.oid && this.oid !==''){
				this.error = false;
				let that = this;
				let u = uni.getStorageSync("userinfo")
					if (u.phone) {
							that.realName = u.realName;
							that.phone = u.phone;
							that.address = u.address;
							that.isshow = true;
					} else {
						uni.navigateTo({
							url: '/pages/userreg/userreg?f=u'
						})
					}
			}
		},
		methods: {
			inoutChanged(e){
				this.inout = e.target.value;
			},
			jksmChanged(e) {
				this.jksm = e.target.value;
			},
			twChanged(e) {
				this.tw = e.target.value;
			},
			remarkBlur(e) {
				this.remark = e.target.value;
			},
			submit(){
				let that = this;
				uni.showModal({
				    title: '提示',
				    content: '确认提交？',
				    success: function (res) {
				        if (res.confirm) {
								let p = {jksm:that.jksm,tw:that.tw,inoutstr:that.inout,remark:that.remark,oid:that.oid}
								console.log(p)
								that.$sendhttp("/Weixin/addRecord.dhtml", p, function(data) {
										uni.redirectTo({
											url: '/pages/add-member/addRecoredSuccess'
										})
								});
				}
				    }
				});
			}
		}
	}
</script>

<style>
	page {
		background: #fff;
	}

	.title {
		color: #007AFF;
		font-size: 21px;
		font-weight: 700;
		display: flex;
		justify-content: center;
		margin: 20rpx 10px;
	}

	.list-item,
	.list-item-no,
	.list-item-mul {
		display: flex;
		justify-content: space-between;
		border: 1px solid lightgray;
		line-height: 50px;
		margin: 20px 20px;
		padding: 0 10px;
	}

	.list-item-no {
		border: none;
		margin-bottom: -30px;
		font-weight: 700;
		    font-size: 21px;
	}

	.list-item-mul {
		line-height: 30px;
		padding: 10px;
		flex-direction: column;
	}

	.list-item-col {
		line-height: 30px;
		padding: 10px;
		flex-direction: column;
	}

	.uni-radio-group {
		display: flex;
		    flex-direction: column;
		justify-content: space-around;
	}

	.uni-radio-group-col {
		display: flex;
		flex-direction: column;
		justify-content: space-around;
	}

	.uni-list-cell {
		flex-direction: row;
		display: flex;
	}
</style>
